﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

/*
Developed By: Sujeet Kumer
Developed On: 11th Feb 2010
Description: The code provides User to find the web list   
*/ 

namespace SiteProjects.Classes
{
    public class TaskLibrary
    {
        SqlConnection connection;
        SqlCommand command;
        SqlDataAdapter da;
        DataSet ds;
        string UserID;

        public DataSet FindWebList()
        {
            //oWebsite object get all the current data on sharepoint application
            Microsoft.SharePoint.SPWeb oWebsite = Microsoft.SharePoint.SPContext.Current.Web;
            //get the loginname on sharepoint site 
            UserID = oWebsite.CurrentUser.LoginName.ToString();
            ds = new DataSet();
            //connection fetch by web.config file and stored procedure call
            connection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ASPNET_WSS_Content"].ConnectionString);
            command = new SqlCommand("proc_WebList", connection);
            command.Parameters.AddWithValue("@UserName", UserID.ToString());
            command.CommandType = CommandType.StoredProcedure;
            connection.Open();
            da = new SqlDataAdapter();
            da.SelectCommand = command;
            da.Fill(ds);
            connection.Close();
            return ds;
        }
    }
}
